<%@ include file="IsProff.jsp"%>
<%@ page import="java.util.*, database.*, java.text.*" %>

<%
try{
String profID = (String) session.getAttribute("ProfID");

if(profID != null ) {
	
        DBCon db = new DBCon();
	String name;
	String col = "";
	String data = "";
	String[] events = new String[2];
        SimpleDateFormat time = new SimpleDateFormat("hh:mm:ss a");
	SimpleDateFormat day = new SimpleDateFormat("MM/dd/yyyy");
	events[0]= day.format(new Date());
	events[1]= time.format(new Date());
        String type = "";
	
	Enumeration project = request.getParameterNames();

	
	while(project.hasMoreElements())
	{
		name = (String)project.nextElement();
                if(name.equals("type"))
                    type = request.getParameter(name);
		else if(!(name.equals("fColor") || name.equals("fStyle") || name.equals("fSize")))
		{
			col += name+",";
			data += "'"+request.getParameter(name)+"',";
		}
	
	}
	
	
	
		
		
		String[] owner = new String[2];
                owner = db.getOwner(profID);
                name = owner[0]+" "+owner[1];
		col += "status,creation_date,Last_modification_date,professorid";
		data += "'"+type+"','"+events[0]+" "+events[1]+"','"+events[0]+" "+events[1]+"',"+profID;
		
		
		
		
		if(!db.creatProject(col,data))
                db.setEvent("Professor: (" + name + ") add new project"
                        , "Insertion process is successful", "project");
		
	response.sendRedirect("index.jsp");
}
else {
	response.sendRedirect("error.jsp");
}
}
catch(Exception e)
{
    response.sendRedirect("../connectionFailed.jsp?"+e);
}

%>